home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 3
/
Amiga Tools 3.iso
/
audio
/
deliay014
/
dev
/
dev.doc
next >
Wrap
Text File
|
1994-10-18
|
10KB
|
247 lines
Intro
=====
In this directory is located all the developers stuff. As you have probably
already realized, DeliAY can play several AY formats, using proper AY
Player. So, if you have written some ingenious tunes using your own
replayer routine, why not to give it a try and rewrite the player for
MC68000? Or perhaps send me the tunes and the Z80 source and let me see
what can be done?
If you decide to write your own AY Player, please check the Amadeus.S and
include40/misc/AYPlayer.i for more info about the DeliAY<->AYPlayer
interface. Also, before starting your work I strongly recommend to contact
me and to get the most recent info about this problematic available.
Contents
========
src/include40/misc/AYPlayer.i
Main includes, defines how each AY Player and AY Module has to
look like
src/include40/misc/mine.i
Just few asm support macros
src/Amadeus.S
This is the source of the ZXAYAMAD. This is the example, how
your own MC68000 rewrites could look like.
src/ZXAYEMUL.S
This is the source of a very special AY Player, which runs
original Z80 code. Just for your information.
src/emultest.s
Source of emul.test.
src/AYdebugger.S
Source of the AYdebugger. You can see how to write modules
with internal players (for special cases like this one there is
no need to have one special player and one special init module)
tests/AYdebugger
You can use this special standalone module to play with the AY
emulator. Just load it as any other module to DT2.
tests/emul.test
Load it to DT2 to see that ZXAYEMUL debug routine really works.
dev.doc
Obviously this file.
Converting
==========
So, let's assume that you have some marvellous tunes and want to listen to
them on your Amiga. What are your choices?
1) If you have several tunes, which you have written by yourself, using
some widespread music program, you have to check out if there is not
already some special player for that musical program. If not, or if you
have used your own player which were never distributed to the public, you
might decide to write your own AY Player. To do that, read AYPlayer.i to
see how every AY player interfaces with PlayAY. Also, you can check the
Amadeus.S how such player really looks like. Also note, that in addition to
standard AYMOD header, you will have to specify your own SONG header
structure... Also, you can read Amadeus.S how this might look like.
2) If you have ripped some tune, and you are sure that the same player is
not used with any other tune, it is üprobably not worth to rewrite it to
MC68000. In that case, you might want to use the special Emul Player, which
will emulate the original z80 replay routine with no need to rewrite it.
Typical Emul module looks like this:
incdir 'Include40/'
include misc/AYPlayer.i
incdir ''
b
AYMODHEADER EMUL
dc.w 0 ;no internal player
dc.w creator-*
dc.w misc-*
dc.b 3-1 ;how many songs
dc.b 0 ;which should start first
dc.w songdata-*
songdata dc.w name1-* ;use same name for all three songs.
dc.w data1-*
dc.w name1-*
dc.w data2-*
dc.w name1-*
dc.w data3-*
name1 dc.b 'Venom strikes back',0
creator dc.b 'Ben Daglish',0
misc dc.b 'Venom strikes back, (C) 19?? ????',0
even
data1 dc.b 0,1,2,3 ;channel assignement
dc.w 3*60*50 ;songlen
dc.w 50 ;fadelen
dc.w 0<<8 ;init number to A
dc.w launch-* ;launch structure
dc.w block-* ;block list
data2 dc.b 0,1,2,3
dc.w 9*50
dc.w 1
dc.w 1<<8
dc.w launch-*
dc.w block-*
data3 dc.b 0,1,2,3
dc.w 3*50
dc.w 1
dc.w 2<<8
dc.w launch-*
dc.w block-*
block dc.w 49152 ;put code at address
dc.w e-code ;len
dc.w code-* ;take code from
launch dc.w 0 ;stack / use as EMUL_Block list terminator
dc.w 0 ;init same as first block address
dc.w 49155 ;interrupt
code incbin 'asm:sources/fxs/other/venom.data'
e
For more info about how such module should look, read beginning of
ZXAYEMUL.S.
Few more words about emulation
==============================
It uses cut down version of my emulator I wrote some years ago. All
instructions are emulated, except those RES C,3,(IX+1) and similar (I was
just lazy, no other reason for this). All other like those with IY and IX
halfs + SLIA (AKA SLL) are implemented.
For every song you specify what stack, init number, INIT routine and
INTERRUPT routine emulator should use.
Init number is loaded to all registers (BC,DE,HL,BC',DE',HL',IX,IY + A and
A' which contain MSB) and stack obviously to SP.
All ROM is filled with 255 (because of that popular $FFFF IM 2 trick), all
RAM with 0. At address 0 this code is installed and executed.
call INIT ;whatever you passed in ems_init (or emd_address)
ld hl,INTERRUPT ;from ems_interrupt
ld a,h ;if no interrupt specified, we use the
or l ;im2 interrupt table to find it out
jr nz,ok
ld a,i
ld h,a
dec l
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
ok ld (here+1),hl
loop halt
here call ????
jr loop
ret ;this can be used as dummy init routine
Note that although address 0 contains $cd, address 65535+1 contains 243
(little emulator magic:-), so you can use that popular IM 2 setting which
jumps to 65535 executing JR 65524 there...
I didn't want to run the emulator from interrupts, IMHO it is too
dangerous, if the z80 code hangs. Also, too much serial transfer errors
usually occurs. So the solution is now like this:
Separate process is executed at priority 127. It runs the code described
above. Halt is implemented as waiting for an external signal. Meanwhile,
every interrupt EmulPlayer sends AY registers to the PlayAY, then sends
signal to the emulator process. So the process does not block any
interrupts even if it uses 100% of the CPU time.
So as you can see, no real interrupts are generated by the emulator, thus
playing with DI/EI and IM x has no effect.
While playing already checked tunes this is not that important, but once
you start converting your own tunes, this may become more important:
imagine you execute some code which hangs the z80 (eg. jr $-2). It is not
that bad since we are not hanged as interrupt, but as normal task. Problem
is that the task has priority 127 and it takes all the time, so we can't
stop it from other tasks with lower priority. Solution is simple:
ZXAYEMUL reads the binary environment variable z80debug and sets the
priority according to it. So before testing your own songs, you might want
to type 'setenv z80debug °' or something like that. The song will sound
terrible whenever you do some other activity (move a window or like), but
it will never hang your computer :-)
Other problem is what should the emulator do if it runs some invalid
instruction code. Solution: emulator process dumps all z80 registers and
some internal to the ram:z80debug and disappears. However, the RAM still
remains allocated until you drop the module, so you can simply see what
happened. To see how the debug routine works, try playing emul.test.
Emulation - advantages vs disadvantages
=======================================
Well, I realize that most people are simply too lazy to write their own AY
Player, especially when I have released the ZXAYEMUL, which makes
everything SOOOooo simple. However, they should realize following:
- Emulation is more CPU intensive. One should save his and others' time
and write MC68000 player.
- Emulation consumes much more memory - 64KB for RAM and about 21K for the
emulator plus one more process and stack.
- Frequencies are not fine tuned - simply ayfreq*8 is used. MC68000 players
use special pre-calculated table, so their output is more precise.
- Storing z80 code and data for every tune takes much more space than just
storing the data, which is done for MC68000 players.
So, the following should be taken as general rule:
Use ZXAYEMUL only for your "quickhacks" (when you plan to rewrite the
routine later to MC) to hear it. Also, use it, if there is only really few
tunes using this player (few means aprox. less than 5).
In all other cases you should decide to write MC68000 player.
Never use ZXAYEMUL for collections which have about 20 modules or more and
NEVER for musical programs. In such cases, MC68000 player should be ALWAYS
written.
OK, that's it. If you miss some information here, please refer to includes
and sources first, then try e-mailing me if you do not succeed.
Also, please send me all new tunes and new players. Thank You.
Patrik